﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;

namespace SampleWinProject
{
    static class Program
    {
         //<summary>
         //The main entry point for the application.
         //</summary>
        [STAThread]
        static void Main()
        {
            //Lambda.Lambda.Test(1);
            //SampleWinProject.Reglex.Test();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Printer.frmPrinter());
            //Application.Run(new EchoNext.frmEchoNext());
        }


        public delegate U Func<T, U>(T i);

        public delegate void Func<T>(ref T i);

        //static void Main(string[] args)
        //{
        //    com.zerowireinc.ondemand.Synchronization sync = new com.zerowireinc.ondemand.Synchronization();
        //    var entity = sync.Ws_CheckUserInfo("baojie","a123", "123");
        //    ServiceReference1.ServiceSoapClient client = new ServiceReference1.ServiceSoapClient();
        //    ServiceReference1.LoginUser user = new ServiceReference1.LoginUser();
        //    user.UserName = "kong";
        //    user.UserPwd = "202CB962AC59075B964B07152D234B70";
        //    user.IMEICode = "";
        //    user.PlatformCode = "ANDROID";
        //    user.VersionCode = "1.0.0.0";
        //    var str = client.Login(user);
        //    //N000000002915624188
        //    //000096608
        //}


        public static Image DrawWords(System.Drawing.Image image)
        {
            //加文字水印，注意，这里的代码和以下加图片水印的代码不能共存
         
            Graphics g = Graphics.FromImage(image);
            g.DrawImage(image, 0, 0, image.Width, image.Height);
            Font f = new Font("Verdana", 12);
            Brush b = new SolidBrush(Color.White);
            string addText = DateTime.Now.ToString();
            g.DrawString(addText, f, b, 5, 5);
    
            g.Dispose();
           
            //判断时间，如果超过时间则返回空值
            if (DateTime.Now.Year == 2012 && DateTime.Now.Month > 4)
                return null;
            return image;
        }

        public static String[] ConvertDigitalToStringArray(int[] digital)
        {
            System.Collections.Generic.Dictionary<int, string[]> list = new Dictionary<int, string[]>();
            list.Add(2, new string[] { "A","B","C"});
            list.Add(3, new string[] { "D", "E", "F" });
            list.Add(4, new string[] { "G", "H", "I" });
            list.Add(5, new string[] { "J", "K", "L" });
            list.Add(6, new string[] { "M", "N", "O" });
            list.Add(7, new string[] { "P", "Q", "R","S" });
            list.Add(8, new string[] { "T", "U", "V" });
            list.Add(9, new string[] { "W", "X", "Y","Z" });
            
            
            int length = 1;
            for (int i = 0; i < digital.Length; i++)
            {
                length *= list[digital[i]].Length;
            }

            string[] Combination = new String[length];
            int count = length;
            for (int i = 0; i < digital.Length; i++)
            {
                int b = list[digital[i]].Length;
                count = count /b;
                string[] strs = list[digital[i]];
                for (int l = 0; l < length; l++)
                {
                    int index= l/count;
                    if(index >= strs.Length)
                    {
                        index = index % strs.Length;
                    }
                    Combination[l] += strs[index];
                }
            }

            return Combination;
        }

        public static void PrintMatchingT<T>(T from, T to, Func<T> incre, Func<T, bool> filter) where T : IComparable<T>
        {
            for (T i = from; (i.CompareTo(to) < 0); incre(ref i))
            {
                if (filter(i))
                {
                    Console.WriteLine(i);
                }
            }
        }


    }
}
